home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Message-ID: <w+RYXMD4FC8aRz1@_crisi.blackbox.shnet.org>
- From: CRISI@BLACKBOX.shnet.org (Christian)
- Path: blackbox.shnet.org!CRISI
- Organization: .oO PHANTASM Oo.
- Subject: Re: fastest file read method ??
- Date: Sun, 14 Jan 1996 13:41:27 +0100
- X-Mailer: MicroDot 1.10 [REGISTERED 004fc8]
- References: <w9YbsMD4ACazz9@jeff.dame.shnet.org>
- X-Gateway: ZCONNECT US genepi.shnet.org [UNIX/Connect v0.71]
- MIME-Version: 1.0
- Content-Type: text/plain; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
-
- It was 11.01.1996 at 20:53:48 when JEFF@DAME.SHNET.ORG (Joerg Fenin)
- wrote about "fastest file read method ??":
- JF> Hi!
- JF>
- JF> What is the fastest way to read a file ?
- JF>
- JF> I used fread() and fgets() from the sc.lib of SAS/C, then I used
- JF> FRead() from dos.library but both routines seem to be rather slow
- JF> (FRead() was even slower than fread()).
- JF>
- JF> Is there anything else I could use?
-
- Hello Jeff,
-
- fread(), fwrite(), fgets() and their AmigaDOS counterparts are all
- routines for buffered I/O. This means they have an internal buffer
- that must be maintained, and if you always wirte small amounts of
- data, the whole may become slow in relation to the speed of the
- storage medium, especially if you write to a fast one. The faster your
- storage medium is, the less speed increase there will be when writing
- small amounts of data along with buffered I/O.
-
- fread() and fwrite() are probably faster than FRead() and FWrite()
- because they seem to use a more clever way of buffering along with
- using non-buffered AmigaDOS functions (i.e. Read()/Write()).
-
- If you want to use faster buffered I/O without using fread() and
- fwrite(), you will have to write your own buffering routine. If you
- don't need buffered I/O (e.g. if you read/write large memory blocks
- or if your CPU isn't much faster than your storage medium, e.g. if you
- write to a device in RAM like RAM:, RAD: or FFx: with FMS: assigned to
- RAM:), it's better to go without buffered I/O.
-
- BTW: With SetVBuf()/setvbuf() you can set the type of buffering to
- either a fixed block size (for binary data) or to reading ahead resp.
- delaying the write operation until a \n appears (for ASCII data) or to
- no buffering at all (as far as I remember), but I assume you also
- experimented with this.
-
- Greetings
-
- --
- Christian Wasner (CRISI/ PHANTASM)
- crisi@blackbox.shnet.org
- Sorry, but you haven't won a cookie in today's lottery
-